package com.kfm.company.mapper;

import com.kfm.company.model.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * '@Many' --> <collection column+select></collection>
     * @return
     */
    @Select("select * from kfm.category")
    @Results(id = "categoryResult",
            value = {
                    @Result(id = true, column = "id", property = "id"),
                    @Result(column = "name", property = "name"),
                    @Result(property = "goodsList", column = "id",
                            many = @Many(select = "com.kfm.company.mapper.GoodsMapper.selectByCategoryId"))
            })
    List<Category> selectAll();

}
